<?php 
header("Content-type: text/xml");

require_once 'settings.php';
// // $con = mysql_connect('localhost', 'root', 'super');
// if (!$con)
//   {
//   die('Could not connect: ' . mysql_error());
//   }

// mysql_select_db("db_tursib", $con);
 

// $sql="SELECT id_station, name 
// FROM  t_stations 
//   WHERE latitude is null AND 
//    longitude is null 
//    ORDER BY RAND( ) LIMIT 5 ";

$sql ="select id_station, name  from t_stations as a
  inner join t_station_bus as b
    where a.id_station = b.t_stations_id_station and
     latitude is null AND 
   longitude is null 
  and t_busses_id_bus = '$_GET[id_bus]' ORDER BY RAND( ) LIMIT 5 ";
$result = mysql_query($sql);

//Build Result String
$data = "<?xml version='1.0' encoding='UTF-8'?><xml>" ;
 

// Insert a new row in the table for each person returned
while($row = mysql_fetch_array($result)){
	$data .= "<item>";
    $data .= "<id>$row[id_station]</id>"; 
//   	$data .= "<lat>$row[latitude]</lat>";
//   	$data .= "<long>$row[longitude]</long>";
	$data .= "<name>$row[name]</name>";
//   	$data .= "<direction>$row[direction]</direction>";
//   	$data .= "<busses>$row[busses]</busses>";
	$data .= "</item>";

} 
$data .="</xml>";
echo $data;  

mysql_close($con);
?>